home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Power 1997 October
/
MACPOWER-1997-10.ISO.7z
/
MACPOWER-1997-10.ISO
/
AMUG
/
PROGRAMMING
/
Mac F2C 1.3.5.sit
/
Mac F2C 1.3.5
/
Mac F2C Libraries
/
libF77 Sources
/
d_mod.c
< prev
next >
Wrap
C/C++ Source or Header
|
1995-01-28
|
621b
|
41 lines
#include "f2c.h"
#ifdef KR_headers
#ifdef IEEE_drem
double drem();
#else
double floor();
#endif
double d_mod(x,y) doublereal *x, *y;
#else
#ifdef IEEE_drem
double drem(double, double);
#else
#undef abs
#include "math.h"
#endif
double d_mod(doublereal *x, doublereal *y)
#endif
{
#ifdef IEEE_drem
double xa, ya, z;
if ((ya = *y) < 0.)
ya = -ya;
z = drem(xa = *x, ya);
if (xa > 0) {
if (z < 0)
z += ya;
}
else if (z > 0)
z -= ya;
return z;
#else
double quotient;
if( (quotient = *x / *y) >= 0)
quotient = floor(quotient);
else
quotient = -floor(-quotient);
return(*x - (*y) * quotient );
#endif
}